Blockly.defineBlocksWithJsonArray([{
    "type": "get_current_time",
    "message0": "当前 %1",
    "args0": [
    {
        "type": "field_dropdown",
        "name": "CURRENT",
        "options": [
            ["月", "current_month"],
            ["日", "current_day"],
            ["星期", "current_week"],
            ["时", "current_hour"],
            ["分", "current_minute"]
          ]
    }
    ],
    // "inputsInline": true,
    "output": "Number",
    "colour": "%{BKY_LOOPS_HUE}"
  }]);


      
  Blockly.Lua['get_current_time'] = function(block) {
  
    var code = "";
    var time = block.getFieldValue('CURRENT');

    switch(time){
        case "current_day" : 
            code = 'tonumber(os.date("%d"))';
            // code = 'tonumber(os.date("%d"))';
            break;
        case "current_week" : 
            code = 'tonumber(os.date("%w"))';
            break;
        case "current_hour" : 
            code = 'tonumber(os.date("%H"))';
            break;
        case "current_minute" : 
            code = 'tonumber(os.date("%M"))';
            break;
        case "current_month" : 
            code = 'tonumber(os.date("%m"))';
            break;
        default:
            break;
    }

    var order = Blockly.Lua.ORDER_NONE;  // ORDER_xxx 是指优先级

    return [code,order];
    // [code,order]; // 很多时候要return一个包含代码和优先级的数组 
  };
  
  